﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BoyAudioPlayer : MonoBehaviour {

	AudioSource m_Audio;
	[SerializeField] private MAudioClip[] m_Clips;


	private void Awake() {
		m_Audio = GetComponent<AudioSource>();
	}

	public void PlayMoveSound(float move) {
		move = Mathf.Abs(move);

		if (move == 0) {
			m_Audio.clip = null;
			m_Audio.Stop();
			return;
		}


		if (m_Audio.clip == m_Clips[(int)move - 1].clip) {

			return;
		}

		m_Audio.clip = m_Clips[(int)move-1].clip;
		m_Audio.volume = m_Clips[(int)move-1].volume * SaveData._.muiscSize;
		m_Audio.pitch = m_Clips[(int)move-1].pitch;
		
		m_Audio.Play();

	}

	[System.Serializable]
	struct MAudioClip {
		public AudioClip clip;
		[Range(0, 1)] public float volume;
		[Range(0,1)] public float pitch;
	}

	public void OnLanding(bool play) {
		m_Audio.clip = m_Clips[2].clip;
		m_Audio.volume = m_Clips[2].volume * SaveData._.muiscSize;
		m_Audio.pitch = m_Clips[2].pitch;
		m_Audio.Play();

	}


}
